package com.zycfc.zsf.boot.job.autoconfigure;

import org.springframework.boot.context.properties.*;
import org.springframework.core.env.*;
import org.springframework.beans.factory.annotation.*;
import com.zycfc.zsf.boot.util.text.*;
import javax.annotation.*;

@ConfigurationProperties(prefix = "zsf.boot.job.zk")
public class ZookeeperProperties
{
    @Autowired
    private Environment env;
    private boolean enabled;
    private String servers;
    private String namespace;
    private int baseSleepTimeMilliseconds;
    private int maxSleepTimeMilliseconds;
    private int maxRetries;
    private int sessionTimeoutMilliseconds;
    private int connectionTimeoutMilliseconds;
    private String digest;
    
    @PostConstruct
    public void init() {
        if (null != this.env && (null == this.namespace || this.namespace.trim().isEmpty())) {
            String allNameapce = this.env.getProperty("zsf.all.namespace");
            if (StringUtils.isEmpty(allNameapce)) {
                allNameapce = "dev";
            }
            if (null != allNameapce && !allNameapce.trim().isEmpty()) {
                this.namespace = allNameapce;
            }
        }
    }
    
    public ZookeeperProperties() {
        this.enabled = true;
        this.baseSleepTimeMilliseconds = 1000;
        this.maxSleepTimeMilliseconds = 3000;
        this.maxRetries = 3;
        this.sessionTimeoutMilliseconds = 10000;
        this.connectionTimeoutMilliseconds = 15000;
    }
    
    public Environment getEnv() {
        return this.env;
    }
    
    public boolean isEnabled() {
        return this.enabled;
    }
    
    public String getServers() {
        return this.servers;
    }
    
    public String getNamespace() {
        return this.namespace;
    }
    
    public int getBaseSleepTimeMilliseconds() {
        return this.baseSleepTimeMilliseconds;
    }
    
    public int getMaxSleepTimeMilliseconds() {
        return this.maxSleepTimeMilliseconds;
    }
    
    public int getMaxRetries() {
        return this.maxRetries;
    }
    
    public int getSessionTimeoutMilliseconds() {
        return this.sessionTimeoutMilliseconds;
    }
    
    public int getConnectionTimeoutMilliseconds() {
        return this.connectionTimeoutMilliseconds;
    }
    
    public String getDigest() {
        return this.digest;
    }
    
    public void setEnv(final Environment env) {
        this.env = env;
    }
    
    public void setEnabled(final boolean enabled) {
        this.enabled = enabled;
    }
    
    public void setServers(final String servers) {
        this.servers = servers;
    }
    
    public void setNamespace(final String namespace) {
        this.namespace = namespace;
    }
    
    public void setBaseSleepTimeMilliseconds(final int baseSleepTimeMilliseconds) {
        this.baseSleepTimeMilliseconds = baseSleepTimeMilliseconds;
    }
    
    public void setMaxSleepTimeMilliseconds(final int maxSleepTimeMilliseconds) {
        this.maxSleepTimeMilliseconds = maxSleepTimeMilliseconds;
    }
    
    public void setMaxRetries(final int maxRetries) {
        this.maxRetries = maxRetries;
    }
    
    public void setSessionTimeoutMilliseconds(final int sessionTimeoutMilliseconds) {
        this.sessionTimeoutMilliseconds = sessionTimeoutMilliseconds;
    }
    
    public void setConnectionTimeoutMilliseconds(final int connectionTimeoutMilliseconds) {
        this.connectionTimeoutMilliseconds = connectionTimeoutMilliseconds;
    }
    
    public void setDigest(final String digest) {
        this.digest = digest;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof ZookeeperProperties)) {
            return false;
        }
        final ZookeeperProperties other = (ZookeeperProperties)o;
        if (!other.canEqual(this)) {
            return false;
        }
        final Object this$env = this.getEnv();
        final Object other$env = other.getEnv();
        Label_0065: {
            if (this$env == null) {
                if (other$env == null) {
                    break Label_0065;
                }
            }
            else if (this$env.equals(other$env)) {
                break Label_0065;
            }
            return false;
        }
        if (this.isEnabled() != other.isEnabled()) {
            return false;
        }
        final Object this$servers = this.getServers();
        final Object other$servers = other.getServers();
        Label_0115: {
            if (this$servers == null) {
                if (other$servers == null) {
                    break Label_0115;
                }
            }
            else if (this$servers.equals(other$servers)) {
                break Label_0115;
            }
            return false;
        }
        final Object this$namespace = this.getNamespace();
        final Object other$namespace = other.getNamespace();
        Label_0152: {
            if (this$namespace == null) {
                if (other$namespace == null) {
                    break Label_0152;
                }
            }
            else if (this$namespace.equals(other$namespace)) {
                break Label_0152;
            }
            return false;
        }
        if (this.getBaseSleepTimeMilliseconds() != other.getBaseSleepTimeMilliseconds()) {
            return false;
        }
        if (this.getMaxSleepTimeMilliseconds() != other.getMaxSleepTimeMilliseconds()) {
            return false;
        }
        if (this.getMaxRetries() != other.getMaxRetries()) {
            return false;
        }
        if (this.getSessionTimeoutMilliseconds() != other.getSessionTimeoutMilliseconds()) {
            return false;
        }
        if (this.getConnectionTimeoutMilliseconds() != other.getConnectionTimeoutMilliseconds()) {
            return false;
        }
        final Object this$digest = this.getDigest();
        final Object other$digest = other.getDigest();
        if (this$digest == null) {
            if (other$digest == null) {
                return true;
            }
        }
        else if (this$digest.equals(other$digest)) {
            return true;
        }
        return false;
    }
    
    protected boolean canEqual(final Object other) {
        return other instanceof ZookeeperProperties;
    }
    
    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $env = this.getEnv();
        result = result * 59 + (($env == null) ? 43 : $env.hashCode());
        result = result * 59 + (this.isEnabled() ? 79 : 97);
        final Object $servers = this.getServers();
        result = result * 59 + (($servers == null) ? 43 : $servers.hashCode());
        final Object $namespace = this.getNamespace();
        result = result * 59 + (($namespace == null) ? 43 : $namespace.hashCode());
        result = result * 59 + this.getBaseSleepTimeMilliseconds();
        result = result * 59 + this.getMaxSleepTimeMilliseconds();
        result = result * 59 + this.getMaxRetries();
        result = result * 59 + this.getSessionTimeoutMilliseconds();
        result = result * 59 + this.getConnectionTimeoutMilliseconds();
        final Object $digest = this.getDigest();
        result = result * 59 + (($digest == null) ? 43 : $digest.hashCode());
        return result;
    }
    
    @Override
    public String toString() {
        return "ZookeeperProperties(env=" + this.getEnv() + ", enabled=" + this.isEnabled() + ", servers=" + this.getServers() + ", namespace=" + this.getNamespace() + ", baseSleepTimeMilliseconds=" + this.getBaseSleepTimeMilliseconds() + ", maxSleepTimeMilliseconds=" + this.getMaxSleepTimeMilliseconds() + ", maxRetries=" + this.getMaxRetries() + ", sessionTimeoutMilliseconds=" + this.getSessionTimeoutMilliseconds() + ", connectionTimeoutMilliseconds=" + this.getConnectionTimeoutMilliseconds() + ", digest=" + this.getDigest() + ")";
    }
}
